using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BaseUserGeneratedContentPage
/// </summary>
public abstract class BaseUserGeneratedContentPage : BasePage
{
    public BaseUserGeneratedContentPage()
    {
    }

    protected override void OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Page.Request.QueryString["PostId"] != null)
            {
                try
                {
                    postId = int.Parse(Page.Request.QueryString["PostId"]);
                }
                catch (FormatException)
                {
                }
            }
        }
        base.OnLoad(e);
    }

    private int postId;
    public int PostId
    {
        get { return postId; }
    }

    private Acms.Bll.Post post;
    public Acms.Bll.Post Post
    {
        get 
        {
            if(post == null && postId > 0)
            {
                post = Acms.Bll.Post.GetById(postId);
            }
            return post; 
        }
    }
	


    protected override object SaveViewState()
    {
        ViewState["PostId"] = postId;
        return base.SaveViewState();
    }

    protected override void LoadViewState(object savedState)
    {
        base.LoadViewState(savedState);
        if (ViewState["PostId"] is int)
        {
            postId = (int)ViewState["PostId"];
        }
    }
}

